****************************************************************************
* File-Nale: 	codes_march.do
* Date:		 	02/01/2021
* Author: 		Fred Batista and Felipe Nunes
* Purpose: 		Analysis of March survey data
* Data used: 	datamarch.dta
* Data Output:	None	*/
****************************************************************************

***** RECODES

*** MANIPULATION (0=control; 1=bolsonaro; 2=oms; 3=both)

gen conditions = p13

recode conditions (4=0)

* R had heard of vignette information

encode p14, gen(knew2)

encode p15, gen(knew3)

encode p16, gen(knew4)

recode knew2 knew3 knew4 (2=1) (1=0)

gen knew=.
replace knew=knew2 if knew2!=.
replace knew=knew3 if knew3!=.
replace knew=knew4 if knew4!=.


*** DVs: general views on COVID

* gravity of COVID

encode p17, gen (gravitycov)

recode gravitycov (1=2) (2=3) (3=0) (4=.) (5=1)

gen gravitycov01 = gravitycov/3

* worried about COVID

encode p18, gen (worriedcov)

recode worriedcov (1=2) (2=3) (3=0) (4=.) (5=1)

gen worriedcov01 = worriedcov/3

* press exagerating COVID (DK as middle category)

encode p19, gen (presscov)

recode presscov (1=0) (2=1) (3=2)

gen presscov01 = presscov/2

* general measure of concern about COVID

polychoric gravitycov01 worriedcov01 presscov01

alpha gravitycov01 worriedcov01 presscov01, reverse(presscov01) std

gen concern = (gravitycov01 + worriedcov01 + (1 -presscov01))/3

* dychotomous for cooperation

gen concernd = concern

recode concernd (1=1) (.=.) (else=0)


*** DVs: prevention behavior (DKs and No�s combined)

* getting info on COVID

encode p20, gen(infocov)

recode infocov (1=0) (2=0) (3=1)

* washing hands more frequently

encode p21, gen(handscov)

recode handscov (1=0) (2=0) (3=1)

* increase social distance

encode p22, gen(distcov)

recode distcov (1=0) (2=0) (3=1)

* avoid leaving house

encode p23, gen(leavecov)

recode leavecov (1=0) (2=0) (3=1)

* cancelling trips

encode p24, gen(tripscov)

recode tripscov (1=0) (2=0) (3=1)

* avoiding crowded events

encode p25, gen(eventscov)

recode eventscov (1=0) (2=0) (3=1)

* general measure of prevention

tetrachoric infocov handscov distcov leavecov tripscov eventscov

alpha infocov handscov distcov leavecov tripscov eventscov, std

* all items

gen prevention = (infocov + handscov + distcov + leavecov + tripscov + eventscov)/6

* all items (dummy: full compliance, partial compliance)

gen preventiond = prevention

recode preventiond (1=1) (.=.) (else=0)

* only hardest items

gen prevention2 = (distcov + leavecov + tripscov)/3

* hard items (dummy: full compliance, partial compliance)

gen prevention2d = prevention2

recode prevention2d (1=1)  (.=.)  (else=0)


*** DVs: evaluation of policies (DKs and No�s combined)

encode p26, gen(cancelevent)

recode cancelevent (1=1) (2=0) (3=0)

encode p27, gen(quarentine)

recode quarentine (1=1) (2=0) (3=0)

encode p28, gen(spending)

recode spending (1=1) (2=0) (3=0)

* general measures

tetrachoric cancelevent quarentine spending

alpha cancelevent quarentine spending, std

gen measures = (cancelevent + quarentine + spending)/3

* measures without spending

gen measures2 = (cancelevent + quarentine)/2

* dychotomous for cooperation

gen measuresd = measures

recode measuresd (1=1) (.=.) (else=0)

* correlations between DVs (all positive)

corr concern prevention measures

*** other post-treatment variable

* evaluation of Bolsonaro government�s response

encode p29, gen(bolsoresp)

recode bolsoresp (1=3) (2=1) (3=4) (4=0) (5=2)

gen bolsoresp01 = bolsoresp/4

*** DV (concern about Brazil)

encode p1, gen(concernbr)

recode concernbr (4=1) (else=0)

*** MODERATORS (pre-treatment)

* brazil�s getting better or worse (worse, nowhere and DK, better)

encode p2, gen(brabetterworse)

recode brabetterworse (1=2) (2=1) (3=0) (4=1)

gen brabetterworse01 = brabetterworse/2

* evaluation of bolsonaro�s job performance

encode p3, gen(approval)

recode approval (1=4) (2=.) (3=0) (4=2) (5=3) (6=1) (7=5) 

gen approval01 = approval/5

* bolsonaro�s admin better or worse than expected (Dk combined as middle)

encode p4, gen(bolsoexp)

recode bolsoexp (1=2) (2 3=1) (4=0)

gen bolsoexp01 = bolsoexp/2

* 2018 vote (null and absent as neutral category)

encode p7, gen(vote18)

gen haddadvoter = vote18

recode haddadvoter (2=1) (else=0)

gen bolsovoter = vote18

recode bolsovoter (3=1) (else=0)

* 2022 vote (DK as neutral category)

encode p8, gen(vote22)

gen haddadfuture = vote22

recode haddadfuture (1=1) (else=0)

gen bolsofuture = vote22

recode bolsofuture (2=1) (else=0)

* general feelingsabout bolsonaro

polychoric approval01 bolsoexp01 bolsovoter bolsofuture

alpha approval01 bolsoexp01 bolsovoter bolsofuture, std

gen bolsoeval = (approval01 + bolsoexp01 + bolsovoter + bolsofuture)/4


* partisanship (petistas, antipetistas, otherpartisans, otherantipartisans, nonpartisans)

* party id (0 no, 1 other, 2 PT)

encode p5, gen(partyid)

recode partyid (6 10 12 15=0) (46 47 48 49 50 51 52 53 54=2) (else=1) 

* antiparty id (0 no, 1 other, 2 PT)

encode p6, gen(antiparty)

recode antiparty (10 12 22 23=0) (75 76 77 78 79 80 81 82 83 84 85 86=2) (else=1) 

* petistas

gen petistas = partyid

recode petistas (2=1) (else=0)

* antipetistas

gen antipetistas = 0

replace antipetistas = 1 if antiparty==2 & partyid==0

* otherpartisans

gen otherpartisans = partyid

recode otherpartisans (1=1) (else=0)

* otherpartisans

gen otherantipartisans =0

replace otherantipartisans = 1 if antiparty==1 & partyid==0

* nonpartisans

gen nonpartisans=0

replace nonpartisans=1 if antiparty==0 & partyid==0

* views on science (p9 and p11 inverted scales) - P9 was understood incorrectly by Rs, P11 does not tap the concept

encode p9, gen(science1)
encode p10, gen(science2)
encode p11, gen(science3)
encode p12, gen(science4)

recode science1 science3 (1=6) (2=5) (3=4) (4=3) (5=2) (6=1)

polychoric science1 science2 science3 science4

alpha science1 science2 science3 science4

*gen science= (science1 + science2 + science3 + science4 -4)/20

* only 2 science2 and science4 are highly correlated

gen science= (science2 + science4 -2)/10



*** OTHER VARIABLES (from panel)

* information sources

encode p30, gen(infosource)

gen sourcetv = infosource

recode sourcetv (1=1) (else=0)

gen sourcetv2 = infosource

recode sourcetv2 (1 2 3 4=1) (else=0)

gen sourcenet = infosource

recode sourcenet (5 6=1) (else=0)

gen mediachoice = infosource

recode mediachoice (1=1) (5 6=2) (else=0)

* religion

encode p31, gen(religion)

gen catholic = religion

recode catholic (1=1)(else=0)

gen protestant = religion

recode protestant (2 6=1) (else=0)

* ideologia (higher is right)

encode p32, gen(ideo)

recode ideo (1=0) (2=1) (3=10) (4=2) (5=3) (6=4) (7=5) (8=6) (9=7) (10=8) (11=9)

gen ideo01 = ideo/10

* income

encode p33, gen(income)

recode income (1=0) (2=1) (3=5) (4=6) (5=2) (6=3) (7=4) (8=7) (9=.)

gen income01 = (income)/7

* sex (male=1)

encode var34, gen(male)

replace male = male - 1

* age

gen age = var35

gen age01 = (age-16)/83

* region

encode var36, gen(region)

* social class

encode var37, gen(class)

replace class = (5 - class)

gen class01= class/4

* separating untreated respondents

gen untreat = condition

recode untreat (0 2=1) (1 3=0)


**** DESCRIPTIVE STATISTICS

summarize worriedcov01 measures bolsoeval 1.mediachoice 2.mediachoice 0.mediachoice age01 ideo01 catholic protestant income01 male 1.region 2.region 3.region 4.region 5.region if untreat==1

pwcorr concernbr worriedcov01 measures, sig


***** ANALYSES

* correlates of media choice

mprobit mediachoice bolsoeval age01 ideo01 catholic protestant income01 male i.region if untreat==1, base(0)

margins, dydx(bolsoeval age01 ideo01 catholic protestant income01 male i.region) predict(outcome(1))


* corelates of concern

reg worriedcov01 bolsoeval age01 i.mediachoice ideo01 catholic protestant income01 male i.region if untreat==1

margins, dydx(mediachoice)

reg worriedcov01 c.bolsoeval##i.mediachoice  age01 ideo01 catholic protestant income01 male i.region if untreat==1

margins, at(bolsoeval=(0(.1)1) mediachoice=(1(1)2))

marginsplot, plot1(mcolor(black) connect(direct) lcolor(black)) ci1(lcolor(black) msize(vtiny)) plot2(mcolor(gs12) connect(direct) lcolor(gs12)) ci2(lcolor(gs12) msize(vtiny)) plotdimensions(,label("TV" "Internet")) ytitle("")  xtitle(Bolsonaro Support, size(medlarge) margin(medsmall)) xlabel(0 "Lowest" .1 " " .2" " .3 " " .4 " " .5 " " .6 " " .7 " " .8 " " .9 " " 1 "Highest", labsize(medium)) ylabel(.3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1" , nogrid) title("Concern About Covid-19", color(black) size(large)) legend(col(2) pos(6) ring(1) region(lstyle(none))) yscale(noextend) xscale(noextend) plotregion(style(none) margin(medlarge)) graphregion(color(white) margin(medlarge)) ysize(8) xsize(8) saving(march1)

* correlates of support for measures

reg measures bolsoeval age01 i.mediachoice ideo01 catholic protestant income01 male i.region if untreat==1

margins, dydx(mediachoice)

reg measures c.bolsoeval##i.mediachoice  age01 ideo01 catholic protestant income01 male i.region if untreat==1

margins, at(bolsoeval=(0(.1)1) mediachoice=(1(1)2))

marginsplot, plot1(mcolor(black) connect(direct) lcolor(black)) ci1(lcolor(black) msize(vtiny)) plot2(mcolor(gs12) connect(direct) lcolor(gs12)) ci2(lcolor(gs12) msize(vtiny)) plotdimensions(,label("TV" "Internet")) ytitle("")  xtitle(Bolsonaro Support, size(medlarge) margin(medsmall)) xlabel(0 "Lowest" .1 " " .2" " .3 " " .4 " " .5 " " .6 " " .7 " " .8 " " .9 " " 1 "Highest", labsize(medium)) ylabel(.3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1" , nogrid) title("Support for Measures", color(black) size(large)) legend(col(2) pos(6) ring(1) region(lstyle(none))) yscale(noextend) xscale(noextend) plotregion(style(none) margin(medlarge)) graphregion(color(white) margin(medlarge)) ysize(8) xsize(8) saving(march2)

* combining graphs

grc1leg march1.gph march2.gph, title({bf:March}, size(vlarge)) plotregion(style(none)) graphregion(color(white)) rows(1) iscale(1) name(march)

graph display march, ysize(6) xsize(10)


*******

* infosource replacing media choice


reg worriedcov01 c.bolsoeval##i.infosource  age01 ideo01 catholic protestant income01 male i.region if untreat==1

reg measures c.bolsoeval##i.infosource  age01 ideo01 catholic protestant income01 male i.region if untreat==1



***** END OF CODE
